define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vppz/physical_exam_order/index' + location.search,
                    multi_url: 'vppz/physical_exam_order/multi',
                    import_url: 'vppz/physical_exam_order/import',
                    table: 'vppz_physical_exam_order',
                }
            });

            var table = $("#table");


            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        {field: 'order_no', title: '订单号', operate: 'LIKE'},
                        {field: 'package_name', title: '体检套餐', operate: 'LIKE'},
                        {field: 'total_price', title: '订单总价', operate: 'LIKE'},
                        {field: 'total_price', title: '订单总价', operate: 'LIKE'},
                        {field: 'status', title: __('Status'), searchList: {"0":'待支付',"1":'已支付',"2":'已取消',"3":'已核銷',"4":'已完成'}, formatter: Table.api.formatter.status,custom:{'0':'warning','3':'info','1':'success','4':'success','2':'warning'}},//"0":__('Status 0'),
                        {field: 'exam_person_name', title: '体检人姓名', operate: 'LIKE'},
                        {field: 'exam_person_phone', title: '体检人手机号', operate: 'LIKE'},
                        {field: 'exam_date', title: '体检日期', operate: 'between'},
                        {field: 'exam_time_slot', title: '体检时间', operate: 'LIKE'},
                        {field: 'hospital_name', title: '体检医院', operate: 'LIKE'},
                        {field: 'hexiao_hospital_name', title: '核销医院', operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'pay_time', title: '支付时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'exam_complete_time', title: '核销时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        //{field: 'admin_id', title: __('Admin_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [{
                                    name: 'detail',
                                    title: '订单明细',
									text: '订单明细',
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'vppz/physical_exam_order/detail'
                                }]
						}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
